
import java.io.*;


public class Main{
	public static void main(String[] args){
		try{
			byte[] buffer=new byte[1024];
			FileInputStream fileinputstream=new FileInputStream(new File(args[0]));
			FileOutputStream fileoutputstream=new FileOutputStream(new File(args[1]),true);

			System.out.println("copy file:"+fileinputstream.available()+"byte");
			while(true){
				if(fileinputstream.available()<1024){
					int remain=-1;
					while((remain=fileinputstream.read())!=-1){
						fileoutputstream.write(remain);
					}
					break;
				}
				else{
					fileinputstream.read(buffer);
					fileoutputstream.write(buffer);
				}

			}

			fileinputstream.close();
			fileoutputstream.close();
			System.out.println("copy finish");
		}
		catch(ArrayIndexOutOfBoundsException e){
			System.out.println("exception");
			e.printStackTrace();
		}
		catch(IOException e){
			e.printStackTrace();
		}
	}
}